$(document).ready(function () {	
	//findUserInfo1();
	showLastTimeInfo();
	//findAllRole(rolechooser,"others");//多角色格式如下：var rolechooser = "1001,1002";
	$('#sureZhzrm').click(function () {
		//setEventPlan2Session();
		//alert("fffffffffff");
		//checkEmergency();
		/*
		if(){
			setCookie(ppId,data.proposes.ppId);
		}*/
		var a=$('#tbUserByPCommander1').text();
		var b=$('#tbUserByPViceCommander1').text();
		var c=$('#tbUserByPTeamLeader1').text();
		var d=$('#tbUserDeptByPImplementPlan').text();
		var e=$('#tbUserDeptByPAssistDept1').text();
		//alert(d);
		//alert(a+" "+b+" "+c+" "+d+" "+e);
		/*
		if(a==""){
			alert("请任命总指挥");
			return;
		} */
		if(b==""){
			alert("请任命指挥长");
			return;
		}
		/*
		if(c==""){
			alert("请任现场查控工作组组长");
			return;
		}
		if(d==""){
			alert("请任命实施应急预案部门");
			return;
		} 
		if (e == ""){
			alert("请任命协助部门");
			return;
		}*/
		saveAdmin(a,b,c,d,e);
	});
});


/**
 * 作增加呈批
 */
function saveAdmin(a,b,c,d,e){
	//alert("gggg454545");
	//alert(b);	
    var EId = getCookie(eventId);
    var url = 'work2/LZMReport_saveLastAdmin.action';
    var params = {
        'proposes.tbUserByPViceCommander.UId': b,
        'proposes.tbUserByPTeamLeader.UId': c,
        'proposes.tbUserByPCommander.UId': a,
        'proposes.tbEvent.EId': EId,
		//下面是部门
		'proposes.e': d,
		'proposes.tbUserDeptByPAssistDept.udId': e
    };
    jQuery.post(url, params, saveAdminRst, 'json');
}

/**
 * 作增加呈批
 */
//function saveAdmin(a,b,c,d,e){
//	//alert("gggg454545");
//	//alert(b);	
//    var EId = getCookie(eventId);
//    var url = 'work2/LZMReport_saveAdmin.action';
//    var params = {
//        'proposes.tbUserByPViceCommander.UId': b,
//        'proposes.tbUserByPTeamLeader.UId': c,
//        'proposes.tbUserByPCommander.UId': a,
//        'proposes.tbEvent.EId': EId,
//		//下面是部门
//		'proposes.e': d,
//		'proposes.tbUserDeptByPAssistDept.udId': e
//    };
//    jQuery.post(url, params, saveAdminRst, 'json');
//}

/**
 * 作增加呈批回调函数
 */
function saveAdminRst(data){
	if (data.ajaxRst == "success") {
		//window.location.href="reportTable.jsp?reportTag=succ";
		//checkEmergency();
		//setEventPlan2SessionNoPlan();
		//setCookie(BACK_URL,"event_query_start.jsp")
		//window.location.href="operate_succ.jsp";
		window.location.href="/ag/work/operate_rst_noplan.jsp";
	}else{
		alert("服务器异常！");
	}	
    //
    //alert(data.ajaxRst);
}

function showLastTimeInfo(){
	var url = "/ag/zrt/showLastTimeInfo.action";
	data = {};
	$.post(url,data,showFive);
}

function showFive(data){
	//alert("start");
	//alert(data.commander);
	if(data.commander != null && data.commanderUid != null){
	//	alert("1");
		$('#tbUserByPCommander').text(data.commander);
		$('#tbUserByPCommander1').text(data.commanderUid);
	}
	if(data.viceCommander != null && data.viceCommanderUid != null){
		//alert("2");
		$('#tbUserByPViceCommander').text(data.viceCommander);
		$('#tbUserByPViceCommander1').text(data.viceCommanderUid);
	}
	if(data.teamLeader != null && data.teamLeaderUid != null){
		//alert("3");
		$('#tbUserByPTeamLeader').text(data.teamLeader);
		$('#tbUserByPTeamLeader1').text(data.teamLeaderUid);
	}
	if(data.assistDept != null && data.assistDeptDid != null){
		//alert("4");
		$('#tbUserDeptByPAssistDept').text(data.assistDept);
		$('#tbUserDeptByPAssistDept1').text(data.assistDeptDid);
	}
	if(data.implementPlan != null){
		//alert("5");
		$('#tbUserDeptByPImplementPlan').text(data.implementPlan);
		//$('#tbUserByPTeamLeader1').text(data.teamLeaderUid);
	}
		
}

